function state(){
	document.getElementById("regist").style.display="block";
	document.getElementById("loginPage").style.display="none";
}

function regist() {
		var user_name;
		var user_password;
		var xmlhttp;
		var xmlhttp = new XMLHttpRequest();
        
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				if (xmlhttp.responseText == 1) {
					document.getElementById("reply").innerHTML="注册成功，请登录";
					setTimeout("window.location.reload()",1000) ;
				}else{
					document.getElementById("reply").innerHTML=xmlhttp.responseText;
					setTimeout("window.location.reload()",1000) ;
				}
			};
		}
		xmlhttp.open("POST", "/index/index/regist", true);
		xmlhttp.setRequestHeader("Content-type",
				"application/x-www-form-urlencoded");
		user_name = document.getElementById("registuser_name");
		user_password = document.getElementById("registuser_password");

		xmlhttp.send("user_name="+user_name.value+"&user_password="
				+user_password.value);
	}

function login(){
	var user_name;
	var user_password;
	var xmlhttp;
	var xmlhttp=new XMLHttpRequest();
	
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
	    	document.getElementById("login").value=xmlhttp.responseText;
	    	document.getElementById("loginPage").style.display="none";

	    	if(xmlhttp.responseText=="退出")
	    	{
	    		 document.getElementById("reply").innerHTML="登录成功";
				 setTimeout("window.location.reload()",1000) ;
	    	}else{
	    		 document.getElementById("reply").innerHTML="用户不存在，请注册后再登录";
				 setTimeout("window.location.reload()",1000) ;
	    	}
	    	//document.getElementById("post").style.display="block";
	    }
	 };
	xmlhttp.open("POST", "/index/index/login", true);
	xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	user_name=document.getElementById("user_name");
	user_password=document.getElementById("user_password");
	
	xmlhttp.send("user_name="+user_name.value+"&user_password="+user_password.value);
	
	
}
 function show(dis){
    document.getElementById(dis).style.display="block";
    }

 function post(){
	var xmlhttp;
	var xmlhttp=new XMLHttpRequest();
	var title;
	var content;
	var user_id
	var create_time;
	
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
	    	if(xmlhttp.responseText==1)
	    	{
	    		 document.getElementById("reply").innerHTML="发帖成功";
				 setTimeout("window.location.reload()",1000) ;
	    	}else{
	    		 document.getElementById("reply").innerHTML="发帖失败";
				 setTimeout("window.location.reload()",1000) ;
	    	}
	    }
	 }
	
	xmlhttp.open("POST", "/index/index/post", true);
	xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	if(!(document.getElementById("user_id").value)){
		document.getElementById("reply").innerHTML="未登录状态，请登录后再发帖";
		setTimeout("window.location.reload()",1000) ;
	}else{
		title=document.getElementById("title").value;
		content=document.getElementById("content").value;
		user_id=document.getElementById("user_id").value;
		create_time=document.getElementById("create_time").value;
		xmlhttp.send("title="+title+"&content="+content+"&user_id="+user_id+"&create_time="+create_time);
	}
}
	

  function quit(){
		var xmlhttp;
		var xmlhttp=new XMLHttpRequest();
		
		xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {
		    	document.getElementById("quit").value=xmlhttp.responseText;
		    	
		    	if(xmlhttp.responseText=="登录")
		    	{
		    		 document.getElementById("reply").innerHTML="退出成功";
					 setTimeout("window.location.reload()",1000) ;
		    	}e
		    }
		 };
		
	    xmlhttp.open("POST", "/index/index/quit", true);
		xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlhttp.send();
	}
